Skip to content

fix: implement save mutation in opportunity details edit form#409

Closed
Cy-fox wants to merge 2 commits intoneed4deed-org:developfrom
Cy-fox:fix/opportunity-details-save-401
Closed

fix: implement save mutation in opportunity details edit form#409
Cy-fox wants to merge 2 commits intoneed4deed-org:developfrom
Cy-fox:fix/opportunity-details-save-401

Conversation

@Cy-fox
Copy link
Copy Markdown
Collaborator

@Cy-fox Cy-fox commented Apr 27, 2026

Closes #401

The save button in OpportunityDetails had a placeholder onSubmit that only closed the form without persisting any changes. Added the PATCH mutation and conversion helpers to send form values to the API.

Changes:

  • Add useUpdateOpportunityDetails hook that PATCHes the opportunity endpoint
  • Implement onSubmit in OpportunityDetailsEdit to call the mutation with description, numberVolunteers, languages, activities, skills and schedule
  • Add toLangOptionItems and toOptionItems helpers to convert form state to the OptionItem shape expected by ApiOpportunityPatch
  • Add saveSuccess i18n keys to EN and DE translation files

Cy-fox added 2 commits April 27, 2026 10:46
Closes need4deed-org#393

Appointment times were stored as UTC strings by the API but displayed
without timezone conversion, causing times to appear 2 hours early for
users in CEST (UTC+2).

Changes:
- parseTime in AccompanyingDetails helpers now converts UTC HH:mm strings
  to local time using setUTCHours before extracting via toTimeString
- formatAccompanyingDate in OpportunityCard.helpers now formats the date
  with date-fns and applies the same UTC-to-local conversion for the time
Closes need4deed-org#401

The save button in OpportunityDetails had a placeholder onSubmit that
only closed the form without persisting any changes. Added the PATCH
mutation and conversion helpers to send form values to the API.

Changes:
- Add useUpdateOpportunityDetails hook that PATCHes the opportunity endpoint
- Implement onSubmit in OpportunityDetailsEdit to call the mutation with
  description, numberVolunteers, languages, activities, skills and schedule
- Add toLangOptionItems and toOptionItems helpers to convert form state to
  the OptionItem shape expected by ApiOpportunityPatch
- Add saveSuccess i18n keys to EN and DE translation files
Copy link
Copy Markdown
Collaborator

@nadavosa nadavosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #409 Review: Implement save mutation in opportunity details edit form

Critical: eventDate/eventTime are never sent to the API for event-type opportunities
OpportunityDetailsEdit.tsx onSubmit: When isEventType is true, the form shows eventDate and eventTime fields, but the mutation payload only includes description, numberVolunteers, languages, activities, skills, and schedule. Event date/time are collected from the user and then silently discarded.

High: toLangOptionItems matches by translated display name, not by canonical ID
toLangOptionItems compares field.value (a translated language name in the user's locale) against apiLanguage.title (the English/canonical name). In German locale, "Arabisch" won't match "Arabic" — the language gets silently dropped from the payload. The lookup should use language id throughout, not the string title.

Medium: parseTime timezone bug propagated to two new locations
d.setUTCHours(h, m) followed by d.toTimeString().slice(0, 5) reads UTC-set hours in local time — in UTC+2 this displays 2 hours ahead. This was a pre-existing bug, but the PR copies it into formatAccompanyingDate in OpportunityCard.helpers.tsx. Should use String(d.getUTCHours()).padStart(2,'0') + ":" + String(d.getUTCMinutes()).padStart(2,'0') instead.

Low: formatAccompanyingDate added to OpportunityCard.helpers.tsx but not used
The new function is added but no call site in the diff uses it. If speculative, defer to the PR that actually needs it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opportunity profile: edited information in opportunity details is not saved

2 participants